import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { ResourceDto } from './dto/resource.dto';
import { ResourceService } from './resource.service';

@ApiTags('后台管理系统-资源管理')
@Controller('resource')
export class ResourceController {
  constructor(private readonly resourceService: ResourceService) {}
  /**
   * @Author: laotongshu
   * @Date: 2022-10-10 18:15:09
   * @LastEditors: laotongshu
   * @Description: 查询资源列表
   * @param {Object} {}
   * @return {*}
   */
  @ApiOperation({ summary: '查询资源列表' })
  @Get()
  async getResource() {
    return await this.resourceService.getResource();
  }

  /**
   * @Author: laotongshu
   * @Date: 2022-10-10 15:57:54
   * @LastEditors: laotongshu
   * @Description: 创建资源
   * @param {Object} {}
   * @return {*}
   */
  @ApiOperation({ summary: '创建资源' })
  @Post()
  async createResource(@Body() resourceDto: ResourceDto): Promise<any> {
    return this.resourceService.createResource(resourceDto);
  }

  @Get('role')
  async roleList(@Query('id') id?: string) {
    return await this.resourceService.roleList(id);
  }
}
